// pages/ScenicArea/ScenicAreaIntro/index.js
const constant = require('./constant.js')
const common = require('../../../public.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    ScenicNoticeInfo: {},
    storeId: '',
    type: 0,
    facilitiesList: constant.facilitiesList,
    traffic: '',
    scenicIntro: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.data.storeId = options.storeId
    this.setData({
      type: options.type,
      moduleType: options.moduleType
    })
    wx.setNavigationBarTitle({
      title: options.title,
    })
    this.purchaseNotice()
  },
  purchaseNotice() { // 购票须知
    const that = this
    const tempJson = {
      storeId: that.data.storeId
    }
    common.post('/scenicTicket/getScenicNoticeInfo', tempJson, function (res) {
      if (res.status === 200 && res.data) {
        let traffic = res.data.traffic ? res.data.traffic.replace(/<img/gi, "<img class='richImg'") : ''
        let scenicIntro = res.data.introduce ? res.data.introduce.replace(/\<img/gi, '<img class="rich-img" ') : ''
        that.setData({
          ScenicNoticeInfo: res.data,
          traffic,
          scenicIntro
        })
      } else {
        common.showRequestErrMsg(res)
      }
    })
  },
})